Language: Mobile System Language

更新时间:
2024-07-22
下载文档

Language: Mobile System Language

EdgerOS App can get current language information.

Functions

edger.language()

  • Returns: {Promise} Promise object.

Get current EdgerOS language information.

Example

edger.language().then((data) => {
  const { lang, name } = data;
  console.log('Current language:', lang, name);
}).catch(error => {
  console.error(error);
});

async / await

async function language() {
  try {
    return await edger.language();
  } catch (error) {
    console.error(error);
  }
}

The obtained data object contains the following members:

  • lang {String} Language code.
  • name {String} Language name.

The lang and name possible values include:

langname
'zh-CN''中文 (简体)'
'zh-TW''中文 (繁体)'
'en''English'
'fr''français'
'de''Deutsche'
'it''italiano'
'ja''日本語'
'kr''한국어'
'es''Español'
'pt''portugués'

Events

The unified event listener provided by Web-SDK:

const listener = (payload) => {
  // Event handling...
}

// add listener
edger.addEventListener('some-event', listener);

// or 
// onAction() is an alias of addEventListener().
edger.onAction('some-event', listener);

// remove listener
edger.removeEventListener('some-event', listener);

// remove all listeners
edger.removeAllListeners();

language

This event will be generated when EdgerOS switches the language.

Example

const listener = (payload) => {
  const { lang, name } = payload;
  console.log('Current language:', lang, name);
}

edger.addEventListener('language', listener);
文档内容是否对您有所帮助?
有帮助
没帮助